<?php

namespace App\Http\Controllers\Api;

use App\Models\BookType;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\BookType as BookTypeCollection;

class BookTypesController extends Controller
{




    /**
     *
     *
     *
     * @api {get} /book_types 获取所有的书籍类型
     * @apiName BookType book_types
     * @apiGroup BookType
     *
     *
     * @apiParam {int} [gender] 0=>男频,1=>女频
     *
     * @apiVersion 1.0.0
     *
     * @apiSampleRequest /api/book_types
     *
     */
    public function index(Request $request){

        $builder = BookType::query();


        if ($request->has('gender')){
            $builder->where('status',$request->get('gender'));
        }

        $types = $builder->get();

        return BookTypeCollection::collection($types);

    }


}
